<template>
  <div class="CustomerAddForm">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="姓名">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input v-model="form.phone"></el-input>
      </el-form-item>
      <el-form-item style="dispaly:flex;">
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "UserAddForm",
  data() {
    return {
      form: {
        name: "",
        phone: "",
      }
    };
  },
  methods: {
    onSubmit() {
      let _this = this;
      this.$axios({
        url: "/customer/addCustomer",
        method: "post",
        data: _this.form,
      }).then(function (resp) {
        if (resp.data == 1) {
          alert("增加成功");
          location.reload();
        } else {
          alert("增加失败");
        }
      });
    },
  },
};
</script>